/** 
* All Rights Reserved , Copyright (C) 2021 , 青岛鼎信通讯股份有限公司
* 
* BaseFlowActivityService
* 流程活动
* 
* 修改纪录
* 2021-02-06 版本：1.0 lishuming 创建。
* @version 版本：1.0
* @author 作者：lishuming
* 创建日期：2021-02-06
*/
package com.topscomm.base.service.impl;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.topscomm.base.BaseSystemConst;
import com.topscomm.base.pojo.BaseFlowActivityEntity;
import com.topscomm.base.service.IBaseFlowActivityService;
import com.topscomm.base.service.impl.auto.BaseFlowActivityServiceAuto;
import com.topscomm.basic.BasicEntity;
import com.topscomm.basic.util.PrimaryKeyUtil;

@Service(value = "baseFlowActivityService")
@Scope(value = "singleton")
public class BaseFlowActivityService extends BaseFlowActivityServiceAuto implements IBaseFlowActivityService {

	@Override
	protected void beforeInsert(BasicEntity entity) {
		super.beforeInsert(entity);
		if (entity.getId() <= 0) {// 赋值Id和单号
			long[] arrayId = PrimaryKeyUtil.GeneIDs(entity.getTableName(), 1);
			entity.setId(arrayId[0]);
			String code = String.valueOf(arrayId[0]);
			code = BaseSystemConst.BASE_FLOW_ACTIVITY_CODE_PREFIX + code.substring(0, 6) + code.substring(9);
			entity.setValue(BaseFlowActivityEntity.FieldCode, code);
		}
	}

}
